from django.db import models

class Student(models.Model):
    GENDER_CHOICES = (
        ('M', '男'),
        ('F', '女')
    )
    name = models.CharField('姓名', max_length=50)
    age = models.PositiveSmallIntegerField('年龄')
    gender = models.CharField('性别', max_length=1, choices=GENDER_CHOICES)
    email = models.EmailField('邮箱')
    phone = models.CharField('手机号', max_length=11)

    # 索引
    class Meta:
        indexes = [
            models.Index(fields=['name'], name='name_idx'),
            models.Index(fields=['phone'], name='phone_idx'),
            models.Index(fields=['gender', 'age'], name='gender_age_idx')
        ]

    def __str__(self):
        return self.name